# RTS Entry point

from WtfEngine import *;
import WtfGui;
from Control import *;
import Hud;
import Game;
import Society;

# Main menu
gMenu = 0;

def Main(vArg):
	Controller();
	initGUI();


def startGame():
	Static(StaticCreationOptions(), Oblong(100, 10, 100), OblongModel("", Vector(100, 10, 100)));
	
	gameOpts = Controller.GetInst().GetStartGameOptions();
	gameOpts.players = [Player(Society.Society()), Player(Society.Society())];
	
	Controller.GetInst().StartGame(Game.Game(), Hud.Interface(), gameOpts);
	


## Creates the window manager and main menu
def initGUI():
	font = WtfGui.Font("v_gui_font");

	gWm = WtfGui.WindowManager();
	gWm.BindToEvent(KeyDownEvent(InputKey(27,0)));
	DebugPrint("Window manager initialized");

	# Create Main Menu

	gMenu = WtfGui.Menu("Main Menu");
	gMenu.Resize(300, 100);
	DebugPrint("Menu Created");

	lbl = WtfGui.Label("Imperium", font);
	lbl.ExpandToText();
	
	gMenu.AddChild(WtfGui.LayoutPositioner(lbl,
		WtfGui.CentrePositioner(), WtfGui.CentrePositioner()));
	gMenu.AddChild(WtfGui.Button(Function(startGame), "New Game", font));
	gMenu.AddChild(WtfGui.Button(Function
		(lambda: gWm.AddWindow(Options(font), 1)), "Options", font));
	gMenu.AddChild(WtfGui.Button(Function
		(lambda: gWm.SpawnConsole()), "Developer's Console", font));
	gMenu.AddChild(WtfGui.Button(Function(lambda: exit()), "Exit", font));

	gWm.AddChild(WtfGui.LayoutPositioner(gMenu, WtfGui.CentrePositioner(), WtfGui.CentrePositioner()));

	# Activate the GUI
	gWm.WmToggle();

